<?php

/**
 * This file is part of the Codizer package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright   Copyright (c) 2010 Advisa (http://www.advisa.fr)
 * @author      Codizer Core Team <team@codizer.org>
 * @package     Codizer
 */

class f_context_Block
{
	private static $instance;
	private $parameters;
	
	/**
	 * @return f_core_Context
	 */
	private function __construct()
	{
		return $this;
	}
	
	/**
	 * Get singleton instance
	 *
	 * @return f_context_Block
	 */
	public static function getInstance()
	{
		if(self::$instance === null)
		{
			self::$instance = new self();
		}
		return self::$instance;
	}
	
	/**
	 * get setted context lang iso code
	 *
	 * @return string Lang iso code
	 */
	public function getLang()
	{		
		return f_core_Context::getInstance()->getLang();
	}
	
	/**
	 * Reinitialize the block parameters
	 */
	public function removeParameters()
	{
		$this->parameters = null;
	}
	
	/**
	 * Set a new block parameter
	 *
	 * @param string $name
	 * @param mixed $value
	 */
	public function setParameter($name, $value)
	{
		$this->parameters[$name] = $value;
	}
	
	/**
	 * Get a block parameter
	 *
	 * @param string $name
	 * @param mixed $defaultValue
	 * @return mixed or null
	 */
	public function getParameter($name, $defaultValue=null)
	{
		if(isset($this->parameters[$name]))
		{
			return $this->parameters[$name];
		}
        return $defaultValue;
	}
	
	/**
	 * Return all block parameters
	 *
	 * @return array
	 */
	public function getParameters()
	{
		return $this->parameters;
	}
}